/**
 * 
 */
package registnet.courseDemand;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * The RecommendedCourses class holds the list of recommended courses as a list
 * of String of the student. It also has a separate list of major and non-major
 * courses of the student.
 * 
 * @author Dexter Ryan Carrasco
 */
public class RecommendedCourses {

	/** List of Strings of recommended courses of the student */
	private List<String> recommendedCourses;

	/** List of Strings of recommended major courses of the student */
	private List<String> majorCourses;

	/** List of Strings of recommended non-major courses of the student */
	private List<String> nonMajorCourses;

	/** Default Constructor of RecommendedCourses */
	public RecommendedCourses() {
		this.recommendedCourses = new ArrayList<String>();
		this.majorCourses = new ArrayList<String>();
		this.nonMajorCourses = new ArrayList<String>();
	}

	/**
	 * Categorizes the recommended courses into non-major and major courses
	 * 
	 * @param nonMajorCourseList
	 */
	public void categorized(final List<String> nonMajorCourseList) {
		for (final Iterator<String> it = this.recommendedCourses.iterator(); it
				.hasNext();) {
			final String course = it.next();

			if (nonMajorCourseList.contains(course)) {
				this.nonMajorCourses.add(course);
			} else {
				this.majorCourses.add(course);
			}
		}
	}

	/**
	 * Gets the list of major courses
	 * 
	 * @return the majorCourses
	 */
	public List<String> getMajorCourses() {
		return this.majorCourses;
	}

	/**
	 * Gets the list of non major courses
	 * 
	 * @return the nonMajorCourses
	 */
	public List<String> getNonMajorCourses() {
		return this.nonMajorCourses;
	}

	/**
	 * Gets the list of recommended courses
	 * 
	 * @return the recommendedCourses
	 */
	public List<String> getRecommendedCourses() {
		return this.recommendedCourses;
	}

	/**
	 * Checks whether the list of major courses is equal to the specified list
	 * of major courses
	 * 
	 * @param majorCourses
	 * @return true if equal, false otherwise
	 */
	public boolean hasSameMajorCourses(final List<String> majorCourses) {
		return this.majorCourses.hashCode() == majorCourses.hashCode();
	}

	/**
	 * Sets the list of major courses
	 * 
	 * @param majorCourses
	 *            the majorCourses to set
	 */
	public void setMajorCourses(final List<String> majorCourses) {
		this.majorCourses = new ArrayList<String>();
		this.majorCourses.addAll(majorCourses);
	}

	/**
	 * Sets the list of non major courses
	 * 
	 * @param nonMajorCourses
	 *            the nonMajorCourses to set
	 */
	public void setNonMajorCourses(final List<String> nonMajorCourses) {
		this.nonMajorCourses = new ArrayList<String>();
		this.nonMajorCourses.addAll(nonMajorCourses);
	}

	/**
	 * Sets the list of recommended courses
	 * 
	 * @param recommendedCourses
	 *            the recommendedCourses to set
	 */
	public void setRecommendedCourses(final List<String> recommendedCourses) {
		this.recommendedCourses = new ArrayList<String>();
		this.recommendedCourses.addAll(recommendedCourses);
	}

	/*
	 * (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		final StringBuffer sb = new StringBuffer();

		sb.append("MAJOR COURSES = ");
		for (final Iterator<String> it = this.getMajorCourses().iterator(); it
				.hasNext();) {
			sb.append(it.next());
			sb.append(":");
		}

		sb.append("\nNON-MAJOR COURSES = ");
		for (final Iterator<String> it = this.getNonMajorCourses().iterator(); it
				.hasNext();) {
			sb.append(it.next());
			sb.append(":");
		}

		return sb.toString();
	}
}
